/*
 * test.cpp
 *
 *  Created on: May 4, 2011
 *      Author: ilewis
 */
#include "test.h"
#include <complex>
#include <android/log.h>
using namespace std;

extern void NaiveFT(float* inR, float* inI, float* outR, float* outI, int log2_length);
extern void FFT_cpp(float* inR, float* inI, float* outR, float* outI, int log2_length);

typedef void (*fnFFT)(float* inR, float* inI, float* outR, float* outI, int log2_length);
fnFFT algorithms[FFT_ALGORITHM_COUNT] = {
		NaiveFT,
		FFT_cpp
};

void TestFFT () {
	const int log2_len = 3;
	const int len = 1 << log2_len;


	float dataR[len];
	float dataI[len];

	float outputR[FFT_ALGORITHM_COUNT][len];
	float outputI[FFT_ALGORITHM_COUNT][len];

	for (int i=0; i < len; ++i) {
		dataR[i] = ((float)i / (float)len, 0);
		dataI[i] = 0.0f;
	}

	for (int j = 0; j < FFT_ALGORITHM_COUNT; ++j) {
	  algorithms[j](dataR, dataI, outputR[j], outputI[j], log2_len);
	  for (int i=0; i < len; ++i) {
	    __android_log_print(ANDROID_LOG_INFO,"DSP","A%d=> (%f, %f)",
	        j, outputR[j][i], outputI[j][i]);
	  }
	}

}
